<?php /* Smarty version 2.6.18, created on 2010-09-08 14:05:17
         compiled from admin/alumni/member/index.tpl */ ?>
<iframe width=174 height=189 name="gToday:normal:agenda.js" id="gToday:normal:agenda.js" src="<?php echo @APPLICATION_URL; ?>
library/javascript/calendar/ipopeng.htm" scrolling="no" frameborder="0" style="visibility:visible; z-index:999; position:absolute; top:-500px; left:-500px;">
</iframe>
<div id="id_content"></div>
<script type="text/javascript">
	var ajax_icon		 		= '<?php echo @AJAX_INDICATOR_ICON; ?>
';
	var xoad_handler = <?php echo $this->_tpl_vars['xoad_handler']; ?>
;
	
	var g_frmSearch = Array();
	g_frmSearch['keyword'] = '';
	g_frmSearch['page'] = 1;
	g_frmSearch['index'] = '-1';
	g_frmSearch['intake_id'] = '-1';
	g_frmSearch['gender'] = '-1';
	g_frmSearch['status'] = '-1';
	var g_intPage = 1;
	
	
	function changeGender(p_intValue, p_intMemberId)
	{
		disableHandleForm(document.getElementById("frmSearchListMember"), true);
		callAJAX('xoad_handler', 'changegender', $H({mb_id: p_intMemberId, gender: p_intValue}), changeGender_callBack);	
	}
	var changeGender_callBack = function changeGender_callBack(results)
	{
		disableHandleForm(document.getElementById("frmSearchListMember"), false);
		if ( results == "SUCCESS" )
			alert("Action successfully!");
		else if ( results == "FAIL" )
		{
			backListMember();
			alert("Action unsuccessfully!");
		}
	}
	
	
	function changeStatus(p_intStatus, p_intMemberId)
	{
		disableHandleForm(document.getElementById("frmSearchListMember"), true);
		callAJAX('xoad_handler', 'changestatus', $H({mb_id: p_intMemberId, status: p_intStatus}), changeStatus_callBack);	
	}
	var changeStatus_callBack = function changeStatus_callBack(results)
	{
		disableHandleForm(document.getElementById("frmSearchListMember"), false);
		if ( results == "SUCCESS" )
			alert("Action successfully!");
		else if ( results == "FAIL" )
		{
			backListMember();
			alert("Action unsuccessfully!");
		}
	}
	
	function viewMember(p_intMemberId)
	{
		callAJAX('xoad_handler', 'viewmember', $H({id: 'id_content', mb_id: p_intMemberId}));	
	}
	
	function deleteMember(p_intMemberId)
	{
		if ( confirm("Are you sure want to delete this member?") )
		{
			callAJAX('xoad_handler', 'deletemember', $H({mb_id: p_intMemberId}), deleteMember_callBack);	
		}
	}
	var deleteMember_callBack = function deleteMember_callBack(results)
	{
		if ( results == "SUCCESS" )  
		{
			onPage(g_intPage, '');
			alert("Action successfully!");
		}
		else if ( results == "FAIL" )
		{
			alert("Action unsuccessfully!");
		}
	}
	
	function backListMember()
	{
		onPage(g_intPage, '');
	}
	
	function editMember(p_intMemberId)
	{
		callAJAX('xoad_handler', 'editmember', $H({id: 'id_content', mb_id: p_intMemberId}), editMember_callBack);
	}
	var editMember_callBack = function editMember_callBack(results)
	{ if ( results == 0 ) onPage(g_intPage, ''); }
		
	function listMember()
	{
		onPage(g_intPage, '');
	}
	function onPage(p_intPage, attach)
	{
		g_frmSearch['page'] = p_intPage;
		g_intPage = p_intPage;
		callAJAX('xoad_handler', 'searchmember', $H({id: 'id_content', form: g_frmSearch}), searchMember_callBack);
	}
	function searchMember(p_objForm)
	{
		var frm = xoad.html.exportForm('frmSearchMember');
		g_frmSearch = frm;
		callAJAX('xoad_handler', 'searchmember', $H({id: 'id_content', form: frm}), searchMember_callBack);
		return false;
	}
	var searchMember_callBack = function searchMember_callBack(results){}
	function checkFrmEditMember(p_objForm)
	{
		if ( (p_objForm.full_name.value) == "" )
		{
			alert("Please input member's full name!");
			p_objForm.full_name.focus();
			return false;
		}
		var frm = xoad.html.exportForm('frmDoMember');
		callAJAX('xoad_handler', 'doactionmember', $H({form: frm}), checkFrmAddMember_callBack);
		disableHandleForm(document.getElementById("frmDoMember"), true);
		return false;
	}
	
	function checkFrmAddMember(p_objForm)
	{
		if ( (p_objForm.username.value) == "" )
		{
			alert("Please input member's username!");
			p_objForm.username.focus();
			return false;
		}
		if ( (p_objForm.password.value) == "" )
		{
			alert("Please input member's password!");
			p_objForm.password.focus();
			return false;
		}
		if ( (p_objForm.full_name.value) == "" )
		{
			alert("Please input member's full name!");
			p_objForm.full_name.focus();
			return false;
		}
		var frm = xoad.html.exportForm('frmDoMember');
		callAJAX('xoad_handler', 'doactionmember', $H({form: frm}), checkFrmAddMember_callBack);
		disableHandleForm(document.getElementById("frmDoMember"), true);
		return false;
	}
	var checkFrmAddMember_callBack = function checkFrmAddMember_callBack(results)
	{
		disableHandleForm(document.getElementById("frmDoMember"), false);
		if ( results == "EXIST" )
		{
			alert("Username that you want to add existed, please choose another username for adding!");
		}
		else if ( results == "SUCCESS" ) 
		{
			onPage(g_intPage,'');
			alert("Action successfully!");
		}
		else if ( results == "FAIL" ) 
		{
			alert("Action unsuccessfully!");
		}
	}
	
	function addMember()
	{
		callAJAX('xoad_handler', 'addmember', $H({id: 'id_content'}), addMember_callBack);	
	}
	var addMember_callBack = function addMember_callBack(){}
	
	function disableHandleForm(frm, flgDisable)
	{
		for (var n=0; n < frm.elements.length; n++) 
			frm.elements[n].disabled = flgDisable;
	}
</script>